<template>
	<view class="content">

		<view class="body">
			<view class="body-img"></view>
			<view class="center">
				<view class="avatar">
					<image :src="usr.photourl" mode="aspectFill"></image>
				</view>
				<view class="center-button">
					<button @click="updateImg()">更换头像</button>
				</view>
			</view>
		</view>

		<view class="info">
			<ul>
				<li class="info-item">
					<view class="info-item-zhuti" @click="noModify">
						<view class="title">ID</view>
						<view class="cont">
							{{usr.id}}
						</view>
						<view class="icon"><tui-icon name="arrowright" size="25"></tui-icon></view>
					</view>
				</li>
				<li class="info-item">
					<view class="info-item-zhuti" @click="updateInfo()">
						<view class="title">昵称</view>
						<view class="cont">
							{{usr.username}}
						</view>
						<view class="icon"><tui-icon name="arrowright" size="25"></tui-icon></view>
					</view>

				</li>
			</ul>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				usr: {},
				id:'',
				modal: false
			}
		},
		mounted() {
			this.getUsr(this.id);
		},
		onLoad(option){
			this.id=option.usrid;
		},
		methods: {
			getUsr(usrid) {
				uni.request({
					url: 'http://localhost:8081/usr/getUsrById/' + usrid,
					method: 'GET',
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						if (res.statusCode === 200) {
							this.usr = res.data;
						}
					},
					fail: (err) => {
						console.error(err);
					}
				});
			},
			noModify() {
				uni.showModal({
					title: '提示',
					content: 'ID不可修改！',
					showCancel: false
				});
			},
			updateImg(){
				uni.navigateTo({
					url:"../../person/editInfo/updateImg/updateImg"
				})
			},
			updateInfo(){
				uni.navigateTo({
					url:"../../person/editInfo/updateInfo/updateInfo"
				})
			}
		}
	}
</script>

<style>
	@import url(editInfo.css);
</style>